﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Xml.XPath;
using System.Xml.Xsl;
using System.Xml;
using System.Xml.Serialization;
using System.IO;

namespace Com.Easywiki.XSL
{
    class XSLTUtils
    {
        public static void XsltTransform(string xsltFile, string sourceInput)
        {
            XPathDocument myXPathDoc = new XPathDocument(sourceInput);
            XslCompiledTransform myXslTrans = new XslCompiledTransform();
            myXslTrans.Load(xsltFile);
            XmlTextWriter myWriter = new XmlTextWriter("result.html", null);
            myXslTrans.Transform(myXPathDoc, null, myWriter);

        }

        public static object deSerialized(object obj, string xml)
        {
            XmlSerializer serializer = new XmlSerializer(obj.GetType());

            StreamReader reader = new StreamReader(xml);
            object deserialized = serializer.Deserialize(reader.BaseStream);

            return deserialized;
        }
    }
}
